package com.ecspace.knowledgegraphapi.controller;

import com.ecspace.knowledgegraphapi.domain.dto.BusinessInfo;
import com.ecspace.knowledgegraphapi.domain.dto.NodeRelationDTO;
import com.ecspace.knowledgegraphapi.domain.entity.Node;
import com.ecspace.knowledgegraphapi.domain.entity.Relation;
import com.ecspace.knowledgegraphapi.domain.vo.RelationVO;
import com.ecspace.knowledgegraphapi.domain.vo.ResponseResult;
import com.ecspace.knowledgegraphapi.service.IRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: cs
 * @date: 2024-07-01 13:38:08
 * @since: 1.0
 */
@RestController
@RequestMapping("/relation")
public class RelationController {


    @Autowired
    private IRelationService relationService;


    @PostMapping("/saveNodeRelation")
    public ResponseResult<BusinessInfo> saveNodeRelation(@RequestBody NodeRelationDTO relationDTO) {

        BusinessInfo businessInfo = relationService.saveNodeRelation(relationDTO);
        return ResponseResult.success(businessInfo);
    }

    @GetMapping("/list")
    public ResponseResult<List<RelationVO>> listAll() {
        return ResponseResult.success(relationService.listAll());
    }



}
